package Gui;
import java.awt.Color;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import Entity.CustomerActivity;



import controller.MarketingTemplateControl;
import controller.ProductControl;
import controller.RatingControl;

import javax.swing.JComboBox;


// TODO: Auto-generated Javadoc
/**
 * The Class RateCustomerActivity.
 */
public class RateCustomerActivity extends JPanel{
	
	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = -6400283674228776823L;
	
	/** The Order label. */
	public static JLabel OrderLabel;
	
	/** The Order label2. */
	public static JLabel OrderLabel2;
	
	/** The Template id text field. */
	public static JTextField TemplateIDTextField = null;
	
	/** The Template age text field. */
	public static JTextField TemplateAgeTextField = null;
	
	/** The Template geograph text field. */
	public static JTextField TemplateGeographTextField = null;
	
	/** The Template interesting text field. */
	public static JTextField TemplateInterestingTextField = null;
	
	/** The Template importance text field. */
	public static JTextField TemplateImportanceTextField = null;
	
	/** The Template permission text field. */
	public static JTextField TemplatePermissionTextField = null;
	
	/** The Template message text field. */
	public static JTextField TemplateMessageTextField = null;
	
	/** The displaypidbutton. */
	public static JButton displaypidbutton;
	
	/** The confirmation lable. */
	public static JLabel confirmationLable=null;
	
	/** The back button. */
	public static JButton backButton = new JButton("Back");
	
	/** The flag. */
	public String flag=null;
	
	/** The E rate customer. */
	private CustomerActivity ERateCustomer;
	
	/** The C rate customer. */
	private RatingControl CRateCustomer;


;	
	
	/**
	 * Instantiates a new rate customer activity.
	 */
	public RateCustomerActivity()
	{
		super();
		RateCustomers();
	}

	/**
	 * Rate customers.
	 */
	public void RateCustomers(){
		this.setSize( 1500,765 ); //set Frame size
		this.setLayout(null); //set layout
		OrderLabel = new JLabel();     //set new label
		OrderLabel.setBounds(new Rectangle(380, 120, 283, 19));//set label's  size and location
		OrderLabel.setText("Please insert template details:"); 
		OrderLabel.setFont(new Font("Arial", Font.ITALIC,16));
		OrderLabel2 = new JLabel();     //set new label
		OrderLabel2.setBounds(new Rectangle(392, 170, 283, 19));//set label's  size and location
		OrderLabel2.setText("Please choose an action:"); 
		OrderLabel2.setFont(new Font("Arial", Font.ITALIC,12));
		this.add(OrderLabel, null);   //add label to the panel
		this.add(OrderLabel2, null);
		backButton.setBounds(528, 273, 122, 23);   //set button's size and location
		add(backButton);          // add button to the panel
		this.flag="pid";
		
		
		final JComboBox<String> comboBox = new JComboBox<String>();
		comboBox.setBounds(433, 200, 200, 20);
		comboBox.addItem("");
		comboBox.addItem("Rate customer Importance");
		comboBox.addItem("Rate customer Interest");
		add(comboBox);
		
		displaypidbutton = new JButton("Submit");             
			displaypidbutton.addActionListener(new ActionListener() {
				@SuppressWarnings("deprecation")
				public void actionPerformed(ActionEvent arg0) {										
					CRateCustomer=new RatingControl();
					if(CRateCustomer.checkOrder((String)comboBox.getSelectedItem())==1){
						ERateCustomer=new CustomerActivity();
						ERateCustomer.setCImpotance((String)comboBox.getSelectedItem());
						CRateCustomer.RateCus(ERateCustomer.getCImpotance());
						
					}
					else if(CRateCustomer.checkOrder((String)comboBox.getSelectedItem())==2)
					{
						ERateCustomer=new CustomerActivity();
						ERateCustomer.setCInterest((String)comboBox.getSelectedItem());
						CRateCustomer.RateCus(ERateCustomer.getCInterest());
					}
					else
					{
						confirmationLable.setVisible(true);
						confirmationLable.setText("Please choose an option") ;
					}
						 
					confirmationLable.setVisible(true);
					 
				}

			});
			
			displaypidbutton.setBounds(366, 273, 122, 23);      //set button size
			add(displaypidbutton);
			
			confirmationLable = new JLabel("");           // set result label
			confirmationLable.setBounds(380, 355, 314, 69);  // set label's size and location
			add(confirmationLable);                        // add label to the panel
			confirmationLable.setVisible(false);
			
			
		}
	}
